<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=\, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //****************************************************************************************foreach()遍历数组不改变
    let array = [1, 2, 3, 4, 5, 6, 7]
    array.forEach(element => {
        // console.log(element);
    });
    //****************************************************************************************fliter()过滤数组新的数组
    let brr = array.filter((element, index, arr) => {
        return element > 1
    })
    console.log(brr, ' fliter');//(6) [2, 3, 4, 5, 6, 7]原数组不变 返回新数组
    /* ******************************************************************************************some() 返回布尔值*/
    let somes = array.some((element, index, arr) => {
        if (element > 9) {
            return element
        }
    })
    console.log(somes);//false 都能遍历数组，条件成熟返回布尔值不进行计算
    /* ******************************************************************************************arrayfrom()转成数组*/
    var a = 'fghjjk'
    var arrayLike = {
        "0": "1",
        "1": "2",
        "length": 2
    }

    console.log(Array.from(a, i => i + i), 9999);

    var aryz = Array.from(arrayLike, item => item * 2)
    console.log(aryz)// [2, 4]
    /* ******************************************************************************************find()*查找满足条件的返回/
    var arys = [{
        id: 1,
        name: '张三'
    }, {
        id: 2,
        name: '李四'
    }];
    let target = arys.find(item => item.id == 1);
    console.log(target)//{id: 1, name: "张三"}
    /* ******************************************************************************************findindex()返回下标*/
    let ary = [10, 20, 50];
    let index = ary.findIndex((v, i, a) => v == 50);
    console.log(index)//-1
    /* ******************************************************************************************includes()查找条件返回布尔值*/
    let brrr = ["a", "b", "c"];

    let result = brrr.includes('a')
    console.log(result)//true
    result = brrr.includes('e')
    console.log(result)//false
</script>

</html>